﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChineseChess.Game
{
    /// <summary>
    /// 棋盘类
    /// </summary>
    class Chessboard
    {
        /// <summary>
        /// 当前走棋的阵营,true是红子，false是黑子
        /// </summary>
        public static bool CurrectCamp
        {
            get;
            set;
        }

        /// <summary>
        /// 改变走棋阵营
        /// </summary>
        public static void ChangeCamp()
        {
            CurrectCamp = !CurrectCamp;
        }

        /// <summary>
        /// 棋子列表
        /// </summary>
        public static List<Piece> PieceList = new List<Piece>();

        /// <summary>
        /// 根据棋盘获取某点的子
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="pies"></param>
        /// <returns></returns>
        public static Piece getPieByXy(int x,int y, List<Piece> pies)
        {
            for (int i = 0; i < pies.Count; i++)
            {
                var pie = pies[i];
                if(pie.X==x && pie.Y == y)
                {
                    return pie;
                }
            }
            return null;
        }
    }
}
